<?php

include('db.inc.php');



function getList($pid=0,&$result = array(),$spac=0){
	$spac = $spac+2;
	$sql = "SELECT * FROM deepcate WHERE pid = $pid";
	$res = mysql_query($sql);
	while($row = mysql_fetch_assoc($res)){
		$row['catename'] = str_repeat('&nbsp;&nbsp;', $spac).'|--'.$row['catename'];
		$result[] = $row;
		getList($row['id'],$result,$spac);
	}
	return $result;
}


function displayCate($pid=0){
	$rs = getList($pid);
	$str = '';
	$str .= "<select name='cate'>";
	foreach ($rs as $key => $value) {
		$str .= "<option>{$value['catename']}</option>";
	}

	return $str .='</select>';
}
echo displayCate();